<?php
require_once(PTE::getCoreLibsPath().'Response.interface.php');
class Response
{
	public static $instance = null;
	
	public static function getInstance($outputBuffering = true, $obHandler='ob_gzhandler')
	{
		if (is_null(self::$instance) || !self::$instance instanceof IResponse)
		{
			if (self::isCli())
			{
				require_once(PTE::getCoreLibsPath().'CliResponse.class.php');
				self::$instance = new CliResponse($outputBuffering, $obHandler);
			}
			else
			{
				require_once(PTE::getCoreLibsPath().'HttpResponse.class.php');
				self::$instance = new HttpResponse($outputBuffering, $obHandler);
			}
		}
		if (self::$instance instanceof IResponse)
		{
			return self::$instance;
		}
	}
	
	public static function isCli()
	{
		if ($_SERVER['argc']>0)
		{
			return true;
		}
		return false;
	}
}